import 'package:eshi/app/shi/data/Config.dart';
import 'package:eshi/app/shi/data/tabtxt_history.dart';
import 'package:flutter/foundation.dart';

class HistoryConfig {
  static getAll({bool? readOnly,bool? disable}) {
      final hasAll  = TabTxtHistory.all(filter:false).keys.toList();
      if(readOnly!=null){
          return readOnly 
            ? hasAll.toSet().intersection(Config.historyReadOnlyList.toSet()) 
            : hasAll.toSet().difference(Config.historyReadOnlyList.toSet());
      }
      if(disable!=null){
          return disable 
            ? hasAll.toSet().intersection(Config.historyDisableList.toSet()) 
            : hasAll.toSet().difference(Config.historyDisableList.toSet());
      }
      return hasAll;
  }

  static bool isReadOnly(name){
    if(kIsWeb) return true;
    return HistoryConfig.getAll(readOnly: true).contains(name);
  }
}